package com.ms.common;


import lombok.Data;



    @Data
    public class Result<T> {
        private Integer code;  // 状态码：200-成功，401-未授权，500-系统错误等
        private String message; // 响应信息
        private T data;        // 响应数据

        // 成功响应
        public static <T> Result<T> success(T data) {
            Result<T> result = new Result<>();
            result.code = 200;
            result.message = "操作成功";
            result.data = data;
            return result;
        }

        // 失败响应
        public static <T> Result<T> error(String message) {
            Result<T> result = new Result<>();
            result.code = 401;
            result.message = message;

            return result;
        }

    }


